package com.unicom.room.service;

import com.unicom.room.mapper.UserMapper;
import com.unicom.room.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * Created by zl on 2015/8/27.
 */

@Service
public class UserService {

    @Autowired
    private UserMapper userMapper;

    //查询所有的管理人员名单
    public List getAllUserInfo(){
        List<User> list=userMapper.findAllUserInfo();
        //User user=null;
        return list;
    }
    public List getUserInfo(){
        List<User> list=userMapper.findUserInfo();
        //User user=null;
        return list;
    }

    //新增管理人员
    public  int  insertUser(User user) {
        //如果返回1，证明插入成功
        int flag = userMapper.addUser(user);
        return flag;
    }
    //根据用户名查询对应管理人员
    public User selectByUsername(String name) {
        User user = userMapper.selectByUsername(name);
        return user;
    }
    public int updateUser(User user){
        int  flag = userMapper.updateUser(user);
        return flag;
    }

    public int deleteUser(String name){
        int  flag = userMapper.deleteUser(name);
       return flag;
    }

}
